# StartTCL: b
#
#
# This file is part of the StartTCL Startup System
#
# StartTCL is (c) 2006 by Lazarus Long <lazarus.long@bigfoot.com>
# StartTCL is (c) 2006 by Spirit <thehiddenspirit@hotmail.com>
#
# StartTCL is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 2.1 of the License, or (at your option)
# any later version.
#
# StartTCL is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. You can also consult
# the terms of the license at:
#
#		<http://www.gnu.org/copyleft/lesser.html>
#
#
# Name:		SpellEffects_Teleport.tcl
#
# Description:	TCL API procedures
#
# Based on original WAD and on contributions from the community, thanks to all.
#
#


#
#	proc ::SpellEffects::SPELL_EFFECT_TELEPORT_UNITS { to from spellid }
#
proc ::SpellEffects::SPELL_EFFECT_TELEPORT_UNITS { to from spellid } {
	variable TeleportTime

	set time [ clock seconds ]
	set cooldown [ expr { [ info exists ::AI::SpellData($spellid) ] ? [ lindex $::AI::SpellData($spellid) 1 ] : 0 } ]

	if { [ info exists TeleportTime($from,$spellid) ] && [ set timeleft [ expr { $cooldown - $time + $TeleportTime($from,$spellid) } ] ] > 0 } {
		::Say $from 0 [ ::Texts::Get "teleport_not_ready" [ ::Custom::SecondsToTime $timeleft ] ]
		return
	}

	set TeleportTime($from,$spellid) $time

	switch -- $spellid {
		31	{ ::Teleport $to 1 -994.248169 -3830.104004 7.0 }
		33	{ ::Teleport $to 0 -13923.823242 1313.069580 6.0 }
		34	{ ::Teleport $to 0 -13828.068359 1299.230347 7.0 }
		35	{ ::Teleport $to 0 -14002.620117 1271.615479 3 }
		427	{ ::Teleport $to 0 2889.91 -811.148 160.332 }
		428	{ ::Teleport $to 0 -11025.184570 1497.860596 43.195259 }
		442	{ ::Teleport $to 0 -8929 -116 83 }
		444	{ ::Teleport $to 0 -11409.933594 1968.416504 10.427084 }
		445	{ ::Teleport $to 0 -10413.885742 -1136.884888 24.128809 }
		446	{ ::Teleport $to 0 -10531.167969 296.656219 30.964926 }
		665	-
		3561	-
		17334	{ ::Teleport $to 0 -8960.140625 516.265686 96.356819 }
		1936	{ ::Teleport $to 0 -6132 384 395.5 }
		3562	-
		3581	-
		17607	{ ::Teleport $to 0 -5032 -819 495 }
		3563	-
		3577	-
		17611	{ ::Teleport $to 0 1819.708374 238.789505 60.532143 }
		3566	-
		3579	-
		17610	{ ::Teleport $to 1 -1391.0 140.0 22.478 }
		3567	-
		3580	-
		17609	{ ::Teleport $to 1 1552.499268 -4420.658691 8.948024 }
		11362	{ ::Teleport $to 90 -330 -2 -151 }
		11409	{ ::Teleport $to 0 -14319.114258 444.477905 23.054321 }
		12509	-
		12510	{ ::Teleport $to 1 4232.007813 -7802.841309 4.689385 }
		3565	-
		3578	-
		17608	{ ::Teleport $to 1 9951.792969 2145.915771 1327.724854 }
		18960	-
		19027	{ ::Teleport $to 1 7980.842285 -2501.763428 487.576508 }
		556	-
		8690	{
			::Custom::GoHome $from
		}
		default { puts "Can't find teleport for spellid=$spellid" }
	}
}

